#
# libgist driver program config settings
#

"""The libgist driver program executes this Python script to load its
configuration settings. Using Python for this purpose rather than a more
straightforward INI or similar config file enables us to perform all
sorts of arbitrary preprocessing prior to running some (or all) of the
algorithms provided by libgist.

In order to be able to function effectively, this script needs to know a
few relevant details from the libgist driver, which should be passed in
via command line arguments. The first argument should be the full name of
this script. The second argument should be the name of the dataset to be
used to train/test gist algorithms. The third and fourth arguments
specify, respectively, the action to perform and the gist algorithm to
use."""

#---------------------------- ADMINISTRIVIA -----------------------------

# This file is part of libgist.
#
# libgist is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# libgist is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with libgist; if not, write to the Free Software Foundation, Inc., 59
# Temple Place, Suite 330, Boston, MA 02111-1307 USA.

# REVISION HISTORY
#
# $HeadURL: http://libgist.googlecode.com/svn/trunk/conf/config.py $
# $Id: config.py 56 2011-09-03 02:08:01Z libgist@gmail.com $

#------------------------------ IMPORTS --------------------------------

# Add conf subdirectory under the directory where this script is stored
# to the Python module search path. This allows us to put all the config
# settings for different modules in one place instead of littering the
# top-level libgist config directory with a bunch of Python files.
#
# Thus, we can organize the top-level config directory so that it
# contains only one file, viz., this one, while various other
# configuration related files are distributed under appropriate
# subdirectories. For example, the conf subdirectory can contain
# additional config scripts that will be included/sourced/imported by
# this "main" script; a data subdirectory can house various data files
# for the different algorithms; so on and so forth.
import os, sys, string
gist_config_root = os.path.dirname(sys.argv[0]) + os.path.sep
sys.path.append(gist_config_root + 'conf')

# Now that we have setup the module search path to include the conf
# subdirecory, we can import the "sub-modules" containing the config
# settings for the individual libgist algorithms. Per convention, each
# algorithm's config settings are stored in a Python module named
# foo_conf.py, where "foo" stands for the algorithm's name. Furthermore,
# each foo_conf.py defines a class named foo_conf.
from lazebnik_conf import lazebnik_conf

# Other libgist modules
import dataset, utils, local_settings

#------------------------------- MAIN ----------------------------------

# The lists of training and testing images must be specified via a
# dictionary whose keys indicate the different image categories and whose
# values are lists of image file names corresponding to the category key.
if sys.argv[2] == "train":
   training_images = dataset.build_training_list(sys.argv[1])

# For each libgist algorithm foo, the libgist driver program expects a
# Python object named foo to be created by this config script. The
# driver will obtain the value for some setting "bar" by requesting the
# value of the foo.bar member/attribute.
lazebnik = lazebnik_conf()

# Certain operations can be parallelized. This setting specifies the
# number of threads to use when parallelizing parallelizable operations.
num_threads = utils.num_cpu() * local_settings.num_threads_scaler()

#------------------------------------------------------------------------

# So things look consistent in everyone's emacs...
# Local Variables:
# indent-tabs-mode: nil
# End:
